<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="a_vuejs/vue.global.js"></script>

    <style>
        .myDiv{
            width: 100px;
            height: 100px;
            background-color: chartreuse;
        }

        .myDiv2{
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>



</head>

<body>

<div id="myApp">
    <h3> v-for:用来做数组、集合等迭代/循环 </h3>
    <pre>
        v-for="变量名 in 集合"
    </pre>
    <ul>
        <li v-for="id in ids" v-text="id"></li>
    </ul>
    <ol>
        <li v-for="user in users" >id:{{user.id}},userName:{{user.userName}},password:{{user.password}}</li>
    </ol>

    <table border="1">
        <tr>
            <td>序号</td>
            <td>ID</td>
            <td>用户名</td>
            <td>密码</td>
        </tr>
        <tr v-for="(user,key,index) in users">
            <td v-text="index + 1"></td>
            <td v-text="user.id">ID</td>
            <td v-text="user.userName">用户名</td>
            <td v-text="user.password">密码</td>
        </tr>
    </table>

    个人信息:{{zhangsan.id}}
    <br/>
    <ol>
        <li v-for="zs in zhangsan">{{zs}}</li>
    </ol>
    <ol>
        <li v-for="(zs,key) in zhangsan">{{key}}:{{zs}}</li>
    </ol>

    <ul style="list-style: none">
        <li v-for="(zs,key,index) in zhangsan">{{index+1}}、{{key}}:{{zs}}</li>
    </ul>

</div>

</body>

<script>
    const app = Vue.createApp({
        data(){
            return{
                ids:[1,2,3,4,5,6],//数组
                users:[ //数组
                    {id:1,userName:'张三',password:'123456'},//json对象
                    {id:2,userName:'李四',password:'123456'},
                    {id:3,userName:'王五',password:'123456'},
                    {id:4,userName:'赵六',password:'123456'},
                ],
                zhangsan:{
                    id:100,
                    hobbies:['足球','篮球','乒乓球','网球'],
                    sex:'男',
                    height:178
                }
            }
        }
    }).mount('#myApp')
</script>

</html>